import router from "@/router/index"

router.beforeEach((to, from, next) => {
    let token = window.sessionStorage.getItem("token")
    const whiteList = ['/login']
    if (token) {
        if (to.path === '/login') { // 登录跳转到首页
            next('/')
        }else {
            next()
        }
    }else {
        if (whiteList.includes(to.path)) {
            next() // 放行
        }else {
            next('/login') // 跳转登录页面
        }
    }
})
